package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.DeviceMonthlyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.DeviceMonthlyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.DeviceMonthlyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeviceMonthlyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.custom.DeviceMonthlyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeviceMonthlyGasConsumeDao {
    @Autowired
    DeviceMonthlyGasConsumeEntityMapper deviceMonthlyGasConsumeEntityMapper;
    @Autowired
    DeviceMonthlyGasConsumeEntityCustomMapper deviceMonthlyGasConsumeEntityCustomMapper;

    public int insert(DeviceMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deviceMonthlyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceMonthlyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeviceMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deviceMonthlyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deviceMonthlyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeviceMonthlyGasConsumeEntity selectEntity(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMonthlyGasConsumeEntityExt> extList = deviceMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceMonthlyGasConsumeEntity> selectEntityList(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMonthlyGasConsumeEntityExt> extList = deviceMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeviceMonthlyGasConsumeEntity> entityList = new ArrayList<>();
        for (DeviceMonthlyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public DeviceMonthlyGasConsumeEntityExt selectExt(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMonthlyGasConsumeEntityExt> extList = deviceMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeviceMonthlyGasConsumeEntityExt> selectExtList(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeviceMonthlyGasConsumeEntityExt> extList = deviceMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(DeviceMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deviceMonthlyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
